<?php

namespace App\Http\Controllers\Guard\Setting;

use App\Http\Controllers\Common\GuardController;
use App\Models\Setting\SysSetting;
use Illuminate\Http\Request;

class SysSettingController extends GuardController
{
    public function index(Request $request) {
        if($request->isMethod('GET')){
            $records = SysSetting::get();
            return responseSuccess($records->toArray());
        }else{
            $info = $request->input()['settings'];
            foreach ($info as $item) {
                SysSetting::updateOrCreate(['id'=>$item['id']],[
                    'key'=>$item['key'],
                    'val'=>$item['val'],
                    ]);
            }
            return responseSuccess();
        }
    }
}
